package ehui;

import java.lang.reflect.Method;
import java.util.Date;

public class Test {

	public static void main(String[] args) throws Exception {
		Cal c = new Cal();
		Method m = c.getClass().getDeclaredMethod("add", int.class, int.class);
		if (m.isAnnotationPresent(Myannotation.class)) {// 存在注解
			Myannotation ma = m.getAnnotation(Myannotation.class);// 获取注解
			System.out.println("方法执行前：" + ma.before());
			System.out.println(new Date());
			System.out.println(m.invoke(c, 5, 7));
			System.out.println("方法执行后：" + ma.after());
		} else {
			System.out.println(m.invoke(c, 5, 7));
		}
	}

}
